package org.potomak.patientmanager.tools;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *
 * @author mobile
 */
public class Validation {
    
    private static Double minWeight = 0.0;
    private static Double maxWeight = 250.0;
    private static Double minHeight = 0.1;
    private static Double maxHeight = 2.5;

    public static boolean validateWeight(String weight) {
        Double weightDouble = null;
        try {
            weightDouble = new Double(weight.trim());
        } catch (Exception e) {
            return false;
        }

        if (weightDouble > minWeight && weightDouble < maxWeight) {
            return true;
        } else {
            return false;
        }
    }
    
    public static boolean validateHeight(String height) {
        Double heightDouble = null;
        try {
            heightDouble = new Double(height.trim());
        } catch (Exception e) {
            return false;
        }

        if (heightDouble > minHeight && heightDouble < maxHeight) {
            return true;
        } else {
            return false;
        }
    }
    
    public static boolean validateName(String name) {
        return true;
    }

    public static boolean validateDate(String date) {
        Date dateDate = null;
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
        dateFormat.setLenient(false);
        try {
            dateDate = dateFormat.parse(date.trim());
        } catch (Exception e) {
            return false;
        }

        return true;
    }
}
